package com.sanrenzu.chunbo.adapter;

import android.content.Context;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;

import com.bumptech.glide.Glide;
import com.sanrenzu.chunbo.R;
import com.sanrenzu.chunbo.bean.zxb.DataBean;

import java.util.List;

/**
 * Created by My on 2016/8/30.
 */
public class FenLeiGridAdapterRecycler extends RecyclerView.Adapter<RecyclerView.ViewHolder> {
    private List<DataBean> list = null;
    private Context context;
    private LayoutInflater inflater;

    public FenLeiGridAdapterRecycler(Context context,List<DataBean> list){
        this.context=context;
        this.list =list;
        inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    }

    @Override
    public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        View view = inflater.inflate(R.layout.fenlei_adapter,parent,false);
        return new mViewHolder(view);
    }

    @Override
    public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) {
        mViewHolder mHolder = (mViewHolder) holder;
        Glide.with(context).load(list.get(position).getIconUrl()+"").into(mHolder.fenlei_image_adapter_fragment);
    }

    class mViewHolder extends RecyclerView.ViewHolder{

        private ImageView fenlei_image_adapter_fragment;

        public mViewHolder(View itemView) {
            super(itemView);
            fenlei_image_adapter_fragment = (ImageView) itemView.findViewById(R.id.fenlei_image_adapter_fragment);
        }
    }
    @Override
    public int getItemCount() {
        return list.size();
    }
}
